<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>for循环执行相同的代码</title>
    <script>
        // 可以让用户自己控制循环的次数
        var num = prompt('请输入循环的次数: ');
        for (var i = 1; i <= num; i++) {
            console.log('我好累啊');
            
        }
        var res = 0;
        for (var i = 1; i <= 100; i++) {
            res += i;
        }
        console.log('res = ' + res);
        
    </script>
</head>
<body>
    
</body>
</html>